/**
 * 
 */
package com.dx.mes.common.core.dao;

import org.hibernate.LockMode;
import org.hibernate.Session;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;


/**
 * @author J
 *
 */
public interface GenericDao<T extends Serializable, PK extends Serializable> {
	
	/**
	 * leave 1 function 
	 */
    public T get(PK id);

    public T getWithLock(PK id, LockMode lock);
    
	public List<T> list(String hql, Object... values);

	public T uniqueResult(String hql, Object... values) ;
	
	public List<T> listWithLock(String hql, Object... values);
	
	public T uniqueResultWithLock(String hql, Object... values);
	
	public void update(T entity);
	
	public void update2(T entity);

    public void save(T entity);

    public void saveOrUpdate(T entity);
    
    public void saveOrUpdate2(T entity);

    public void saveOrUpdateAll(Collection<T> entities);

    public void delete(T entity);

    public void deleteByKey(PK id);
    
    /**
	 * leave 2 function 
	 */
    
    public Session getCrSession();
    
    public void flushCurSession();
    
    public void flush();
    
    public List find(String queryString);
    
    public List findBySQL(String sql);
	
    public List findBySQL(String sql, Class clazz);
	
    public List findBySQL(String sql, Class clazz, Object... args);
    
    public T comTblRead(String sql);
    
    public T comTblReadLock(String sql, String tbl_name);
    
    public List<T> comTblRead2nd(String sql);
    
    
    /**
	 * leave 2 function 
	 */

    public T load(PK id);

    public T loadWithLock(PK id, LockMode lock);

    public List<T> loadAll();

    public void deleteAll(Collection<T> entities);
    
    public List<T> find(String queryString, Object values);
    
    public List<T> find(String queryString, Object[] values);
    
    public List<T> listBySQL(String strSQL); 
	
    public void lock(T entity, LockMode lockMode);

    public List<String> findDistStringList(String strSQL);
    
    public T findBySQLOnly(String sql);
	
    public long getCountBySql(String sql);

}
